package com.edfeff.bio.adapter.router.api;

import com.alibaba.fastjson.JSON;
import com.edfeff.bio.adapter.router.Controller;
import com.edfeff.bio.adapter.router.Req;
import com.edfeff.bio.http.Constants;
import com.edfeff.bio.http.Request;
import com.edfeff.bio.http.Response;

import java.util.HashMap;
import java.util.Map;

@Controller
public class AuthController {
    @Req("/userinfo")
    public void userinfo(Request request, Response response) {
        System.out.println("invoke userinfo");

        Map<String, Object> uinfo = new HashMap<>();
        uinfo.put("id", 1000);
        uinfo.put("name", "edfeff");
        uinfo.put("version", "0.1");

        response.setContentType("application/json");
        response.setStringBody(JSON.toJSONString(uinfo));
    }

    @Req(value = "/login", method = Constants.POST)
    public void login(Request request, Response response) {
        System.out.println("invoke login");
    }

}
